{include file="public/header" /}
<body class="layui-layout-body">
<div id="LAY_app">
    <div class="layui-layout layui-layout-admin">
        <div class="layui-header">
            <!-- 头部区域 -->
            <ul class="layui-nav layui-layout-left">
                <li class="layui-nav-item layadmin-flexible" lay-unselect="">
                    <a href="javascript:;" layadmin-event="flexible" title="侧边伸缩">
                        <i class="layui-icon layui-icon-shrink-right" id="LAY_app_flexible"></i>
                    </a>
                </li>
                <!-- <li class="layui-nav-item layui-hide-xs" lay-unselect="">
                    <a href="http://www.layui.com/admin/" target="_blank" title="前台">
                        <i class="layui-icon layui-icon-website"></i>
                    </a>
                </li> -->
                <li class="layui-nav-item " lay-unselect="">
                    <a href="javascript:;" layadmin-event="back" title="返回上一页">
                        <i class="layui-icon layui-icon-return"></i>
                    </a>
                </li>
                <li class="layui-nav-item" lay-unselect="">
                    <a href="javascript:;" layadmin-event="refresh" title="刷新">
                        <i class="layui-icon layui-icon-refresh-3"></i>
                    </a>
                </li>

                <!-- <li class="layui-nav-item layui-hide-xs" lay-unselect="">
                    <input type="text" placeholder="搜索..." autocomplete="off" class="layui-input layui-input-search"
                           layadmin-event="serach" lay-action="template/search.html?keywords=">
                </li> -->
            </ul>
            <ul class="layui-nav layui-layout-right" lay-filter="layadmin-layout-right" id="view">

                <!--<li class="layui-nav-item" lay-unselect="" style="color: #0a0a0a">-->
                    <!--登录人：{$Think.session.name}，角色：{$Think.session.rolename}-->
                <!--</li>-->
                <!--<li class="layui-nav-item layui-hide-xs" lay-unselect="">-->
                    <!--<a href="javascript:;" layadmin-event="note" title="便签">-->
                        <!--<i class="layui-icon layui-icon-note"></i>-->
                    <!--</a>-->
                <!--</li>-->
                <li class="layui-nav-item layui-hide-xs" lay-unselect="">
                    <a href="javascript:;" layadmin-event="fullscreen" title="全屏">
                        <i class="layui-icon layui-icon-screen-full"></i>
                    </a>
                </li>
                <li class="layui-nav-item" lay-unselect="" >
                    <!--<img src="" data-original="" class="layui-circle layui-table-img" onerror="this.src='/static/admin/images/head_default.gif'" alt="{:session('rolename')}" title="{:session('rolename')}" >-->
                </li>
                <li class="layui-nav-item" lay-unselect="">
                    <a href="javascript:;" title="{$Think.session.rolename}">
                        <cite>{$Think.session.name}</cite>
                        <span class="layui-nav-more"></span></a>
                    <dl class="layui-nav-child">
                        <!--<dd><a href="javascript:;" onclick="wk.layer_show1('修改头像',$('#headCrop'),700,570)"><i class="fa fa-crop"></i> 修改头像</a></dd>-->
                        <!-- <dd><a href="javascript:;" onclick="wk.layer_show1('修改密码',$('#changePwd'),500,320);"><i class="fa fa-unlock-alt"></i> 修改密码</a></dd> -->
                        <dd><a href="javascript:;" onclick="cache()"><i class="fa fa-history"></i> 清除缓存</a></dd>
                        <hr>
                        <dd  style="text-align: center;"><a  href="javascript:;" onclick="loginOut()"><i class="fa fa-sign-out"></i>退出</a></dd>
                    </dl>
                </li>

                <li class="layui-nav-item layui-hide-xs" lay-unselect="">
                    <a href="javascript:;" layadmin-event="theme" title="皮肤">
                        <i class="layui-icon layui-icon-theme"></i>
                    </a>
                </li>
                <!--<li class="layui-nav-item layui-hide-xs" lay-unselect="">-->
                    <!--<a href="javascript:;" layadmin-event="about"><i-->
                            <!--class="layui-icon layui-icon-more-vertical"></i></a>-->
                <!--</li>-->
                <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-unselect="">
                    <a href="javascript:;" ><i class="layui-icon layui-icon-more-vertical"></i></a>
                </li>
            </ul>
        </div>

        <!--侧边菜单-->
        <div class="layui-side layui-side-menu">
            <div class="layui-side-scroll">
                <div class="layui-logo" style="font-size: 30px">
                    <span>管理系统</span>
                </div>

                <ul class="layui-nav layui-nav-tree" lay-shrink="all" id="LAY-system-side-menu" lay-filter="layadmin-system-side-menu">
                    {if !empty($menulist)}

                        {foreach name="menulist" item="vo" key="k"}

                            {if condition="$k eq '0'"}<!--默认展开第一菜单-->
                                <li data-name="" data-jump="" class="layui-nav-item layui-nav-itemed">
                            {else /}
                                <li data-name="" data-jump="" class="layui-nav-item">
                            {/if}

                                {if condition="$vo.url eq '#'"}
                                    <a href="javascript:;" lay-tips="{$vo.title}" lay-direction="2">
                                        <i class="{$vo.icon} layui-icon"></i>
                                        <cite>{$vo.title}</cite>
                                        <span class="layui-nav-more"></span>
                                    </a>
                                {else /}
                                    <a href="javascript:;" lay-href="{$vo.url}" lay-tips="{$vo.title}"
                                       lay-direction="2">
                                        <i class="{$vo.icon} layui-icon"></i>
                                        <cite>{$vo.title}</cite>
                                    </a>
                                {/if}


                                {if condition="$vo.url eq '#'"}
                                    {if !empty($vo['child'])}
                                        <dl class="layui-nav-child">

                                            {foreach name="$vo['child']" item="v"}
                                                {if condition="$v.url neq '##'"}
                                                    <dd data-name="console">
                                                        <a lay-href="{$v.url}">{$v.title}</a>
                                                    </dd>
                                                    {else /}
                                                    <dd data-name="grid">
                                                        <a href="javascript:;">{$v.title}<span class="layui-nav-more"></span></a>
                                                        <dl class="layui-nav-child">
                                                            {if !empty($v['child'])}
                                                                {foreach name="$v['child']" item="z"}
                                                                <dd data-name="list"><a lay-href="{$z.url}">{$z.title}</a></dd>
                                                                {/foreach}
                                                            {/if}
                                                        </dl>
                                                    </dd>
                                                {/if}
                                            {/foreach}

                                        </dl>
                                    {else /}

                                    {/if}
                                {/if}

                            </li>
                        {/foreach}

                    {/if}

                </ul>
            </div>
        </div>
        <!-- 页面标签 -->
        <div class="layadmin-pagetabs" id="LAY_app_tabs">
            <div class="layui-icon layadmin-tabs-control layui-icon-prev" layadmin-event="leftPage"></div>
            <div class="layui-icon layadmin-tabs-control layui-icon-next" layadmin-event="rightPage"></div>
            <div class="layui-icon layadmin-tabs-control layui-icon-down">
                <ul class="layui-nav layadmin-tabs-select" lay-filter="layadmin-pagetabs-nav">
                    <li class="layui-nav-item" lay-unselect="">
                        <a href="javascript:;"><span class="layui-nav-more"></span></a>
                        <dl class="layui-nav-child layui-anim-fadein">
                            <dd layadmin-event="closeThisTabs"><a href="javascript:;">关闭当前标签页</a></dd>
                            <dd layadmin-event="closeOtherTabs"><a href="javascript:;">关闭其它标签页</a></dd>
                            <dd layadmin-event="closeAllTabs"><a href="javascript:;">关闭全部标签页</a></dd>
                        </dl>
                    </li>
                </ul>
            </div>
            <div class="layui-tab" lay-unauto lay-allowClose="true" lay-filter="layadmin-layout-tabs">
                <ul class="layui-tab-title" id="LAY_app_tabsheader">
                    <li lay-id="/"><i class="layui-icon layui-icon-home"></i></li>
                </ul>
            </div>
        </div>

        <!-- 主体内容 -->
        <div class="layui-body" id="LAY_app_body">
            <div class="layadmin-tabsbody-item layui-show">
                <iframe src="{:url('Index/indexPage')}" frameborder="0" class="layadmin-iframe"></iframe>
            </div>
        </div>

        <!-- 辅助元素，一般用于移动设备下遮罩 -->
        <div class="layadmin-body-shade" layadmin-event="shade"></div>
    </div>
</div>
{include file="public/footer" /}
<!--修改密码-->
<div id="changePwd" style="display:none;">

    <div class="layui-fluid layui-col-xs12">
        <div class="layui-card-body layui-form layui-form-pane">
            <div class="layui-form-item ">
                <div class="layui-inline">
                    <label class="layui-form-label">当前密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="old_pwd"  placeholder="输入当前密码" lay-verify="required|oldpwd" class="layui-input" autocomplete="off"/>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">新密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="new_pwd"  placeholder="输入新密码" lay-verify="required|newpwd" class="layui-input" autocomplete="off"/>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">确认密码</label>
                    <div class="layui-input-inline">
                        <input type="password" name="r_pwd"  placeholder="输入确认密码" lay-verify="required|rpwd" class="layui-input" autocomplete="off"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="component-form-element">确认修改
                        </button>
                        <button class="layui-btn layui-btn-primary" onclick="layer.closeAll()">关闭</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--个人信息-->
<div id="pInfo" style="display:none;">
    <div class="layui-fluid layui-col-xs12">
        <div class="layui-card-body layui-form layui-form-pane">
            <div class="layui-row layui-form-item ">
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" style="cursor:not-allowed;" value="{:session('username')}" disabled/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">角&nbsp;&nbsp;&nbsp;&nbsp;色</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" style="cursor:not-allowed;"  value="{:session('rolename')}" disabled/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">手机号</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input" style="cursor:not-allowed;" value="{:session('phone')}" disabled/>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">描&nbsp;&nbsp;&nbsp;&nbsp;述</label>
                    <div class="layui-input-block">
                        <textarea class="layui-textarea"style="cursor:not-allowed;resize:none" disabled>{:session('describe')}</textarea>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>

    layui.use(['form'], function() {
        var form = layui.form;
        form.verify({
            oldpwd:function(value,item){
                var checkResult = "";
                $.ajax({
                    url:"{:url('Usercenter/ajaxGetPassword')}",
                    type:'post',
                    data:"old_pwd="+value +"&type=checkPassword",
                    async: false,//必须同步
                    success:function(res){
                        if(res.code == 100){
                            checkResult = "当前密码错误";
                        }
                    }
                })
                return checkResult;
            },
            newpwd: [/^[\S]{6,16}$/,'密码必须6到16位，且不能出现空格'],
            rpwd:function(value,item){
                if(!/^[\S]{6,16}$/.test(value)){
                    return '密码必须6到16位，且不能出现空格';
                }
                var newpwd = $('input[name=new_pwd]').val();
                if(newpwd != value){
                    return "两次输入密码不一致";
                }
            }

        });
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('User/editPwd')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 1) {
                        wk.success(res.msg,'',"{:url('Login/loginOut')}");
                    } else {
                        wk.error(res.msg,'$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
                    }
                }
            })
        });
    });

    var loginOut = function(){
        layer.confirm('你确定要退出吗？', {icon: 3,title:'提示'}, function(index){
            layer.close(index);

            $.ajax({
                url:"{:url('Login/loginOut')}",
                type:'post',
                dataType:'json',
                //data:data.field,
                success:function(res){

                    if(res.code==1){
                        layer.msg(res.msg,{icon:1,time:1000,shade:0.1},function() {
                            window.location.href=res.data;
                        });

                    }else{
                        layer.alert('退出失败');
                    }

                }
            })

        });
    }
    //清除缓存
    var cache = function(){
        layer.confirm('你确定要清除缓存吗？', {icon: 3, title:'提示'}, function(index){
            $.getJSON("{:url('login/clear')}",function(res){
                if(res.code == 1){
                    wk.success(res.msg);
                }else{
                    wk.error(res.msg);
                }
            });
        })
    }
</script>
</body>
</html>